<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">
<script>
    //获取文本框对象
    let sum = document.querySelector("#i1");
  if(!isNaN(sum.value)){
    function f(x) {
        let imgName = x==1?"../b.jpeg":"../c.jpeg";//得到图片名
        /*let c =0;
        while (c<sum.value) {
            c++;
        switch (x) {
        case 1 :
            let i1 = document.createElement("img");
          i1.src = "../b.jpeg";
          document.body.append(i1);
          break;
          case 2 :
              let i2 = document.createElement("img");
            i2.src="../c.jpeg";
            document.body.append(i2);*/

        for (let i=0; i<sum.value; i++){
            let img = document.createElement("img");
            img.width=50;
            img.height=50;
            img.src=imgName;
            document.body.append(img);
      }
    }

  }
</script>
</body>
</html>